<template>
	<div class="headerbox">
		<div class="top" :style="{width:(screenWidth>=1400?'1400px':'1200px')}">
			<div style="display: flex;align-items: center;box-sizing: border-box;">
				<span style="height: 100%;" @click="$router.push('/index')"><img src="../assets/image/logo.png"></span>
				<div style="margin-left: 80px;">
					<span @click="jumpMenu(3)" :class="menuState == 3 ? 'hoverspan' : ''" style="font-weight: 600;">项目管理</span>
					<span @click="jumpMenu(4)" :class="menuState == 4 ? 'hoverspan' : ''" style="font-weight: 600;margin-left: 80px;">考试设置</span>
					<span @click="jumpMenu(1)" :class="menuState == 1 ? 'hoverspan' : ''" style="font-weight: 600;margin-left: 80px;">阅卷管理</span>
					<span @click="jumpMenu(2)" :class="menuState == 2 ? 'hoverspan' : ''" style="margin-left: 80px;font-weight: 600;">成绩管理</span>
				</div>
			</div>
			<div>
				<!-- <ul>
					<li><router-link to="/index" active-class="hover">首页</router-link></li>
					<li @click="gnNav">学校信息</li>
					<li @click="gnNav1">答卷扫描</li>
					<li><router-link to="/mymission" active-class="hover">在线阅卷</router-link></li>
					<li><router-link to="/schoollevel" active-class="hover">成绩查询</router-link></li>
				</ul> -->
				<!-- <span v-if="isLogin=={}" @click="login">登录</span> -->
				<p>
					运营部
					<b @click="quite">退出</b>
				</p>
			</div>
		</div>
		<!-- <div class="toast" v-if="isToast">
			<p v-html="toastText"></p>
			<span>2s关闭</span>
		</div> -->
	</div>
</template>

<script>
	import {loginQuestion} from '../api/api.js'
	export default{
		data(){
			return {
				screenWidth:'',
				menuState: this.getMenuStateFromStorage() || 3,
			}
		},
		mounted() {
			this.menuState=this.getMenuStateFromStorage()
			this.screenWidth = document.body.clientWidth
		},
		methods:{
			quite(){
				loginQuestion().then(res=>{
					this.$router.push('/login')
					localStorage.removeItem('accessToken')
					sessionStorage.removeItem('menuState')
				})
			},
			jumpMenu(index) {
				if (index == 1) {
					// 阅卷跟踪工具
					this.$router.push('/markingexamlist')
				} else if (index == 2) {
					// 数据分析工具
					this.$router.push('/dataAnalysis')
				} else if (index == 3) {
					// 项目管理
					this.$router.push('/projectmanage')
				}else{
					// 考试设置
					this.$router.push('/examsetting')
				}
				this.saveMenuStateToStorage(index)
				this.menuState = index
			},
			saveMenuStateToStorage(state) {
			  sessionStorage.setItem('menuState', state);
			},
			getMenuStateFromStorage() {
			  return sessionStorage.getItem('menuState');
			},
		},
	}
</script>

<style scoped>
	.headerbox{
		height:80px;
		background:#fff;
		width:100%;
		box-shadow: 0px 2px 6px 0px rgba(0,0,0,0.11);
	}
	.top{
		box-sizing: border-box;
		width:1400px;
		margin:0 auto;
		height:80px;
		display: flex;
		justify-content:space-between;
		line-height:80px;
		font-size:20px;
		color:#101010;
	}
	.top div{
		display: flex;
	}
	.top div ul{
		margin-right:100px;
		font-size:18px;
		display: flex;
		
	}
	.top div ul li{
		margin:0 25px;
		padding:0 10px;
		cursor: pointer;
	}
	.top div ul li a{
		display: block;
		position:relative;
		color:#101010;
	}
	.top div ul li a:hover:after,.top div ul li a.hover:after{
		content: '';
		width:100%;
		height:2px;
		background:#101010;
		border-radius:10px;
		position:absolute;
		left:0;
		bottom:20px;
	}
	.top div p{
		display: flex;
		align-items: center;
	}
	.top div p b{
		display: block;
		border:solid 1px #5677FB;
		font-size:14px;
		padding:0 15px;
		margin-left:20px;
		height:30px;
		line-height:30px;
		cursor: pointer;
	}
	.top div span{
		cursor: pointer;
	}
	.top img{
		margin-top:15px;
	}
	.toast{
		position:fixed;
		padding:10px 30px 15px;
		box-shadow: 1px 1px 4px rgba(0,0,0,0.4);
		border-radius: 5px;
		font-size:0.9rem;
		background:#fff;
		color:#fff;
		left:50%;
		top:50%;
		transform: translate(-50%,-50%);
		z-index:1000;
	}
	.toast p{
		color:#000;
		font-size:16px;
	}
	.toast p i{
		display: block;
		color:seagreen;
		text-align: center;
		font-size:60px;
		margin-bottom:10px;
	}
	.toast span{
		display: block;
		font-size:12px;
		color:#999;
		text-align: center;
		padding-top:5px;
	}
	.hoverspan {
		color: #165DFF;
	}
</style>
